<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>YZNCMS后台管理系统</title>
    <meta name="author" content="YZNCMS">
    <link rel="stylesheet" href="__STATIC__/libs/layui/css/layui.css">
    <!-- 布 局 样 式 -->
    <link rel="stylesheet" href="__STATIC__/admin/css/global.css?v={$Think.config.version.yzncms_release}" />
    <link rel="stylesheet" href="__STATIC__/admin/css/dzd.css?v={$Think.config.version.yzncms_release}">
    <link rel="stylesheet" href="__STATIC__/common/font/iconfont.css?v={$Think.config.version.yzncms_release}">
    <script type="text/javascript">
    //全局变量
    var GV = {
        'site':{$site|raw|json_encode}
    };
    </script>
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
    <!-- 布 局 框 架 -->
    <div class="layui-layout layui-layout-admin">
        <!-- 顶 部 样 式 -->
        <div class="layui-header">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <div class="logo"><i class="layui-icon layui-icon-component"></i></div>
                <!-- 标 题 -->
                <span class="title">YznCMS后台</span>
            </div>
            <!-- 顶 部 左 侧 功 能 -->
            <ul class="layui-nav layui-layout-left">
                <li class="collapse layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
                <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
            </ul>
            <!-- 多 系 统 菜 单 -->
            <div id="control" class="layui-layout-control"></div>
            <!-- 顶 部 右 侧 菜 单 -->
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide-xs"><a href="{$Think.ROOT_URL}" target="_blank" class="layui-icon layui-icon-website"></a></li>
                <!-- <li class="layui-nav-item layui-hide-xs"><a href="#" class="menuSearch layui-icon layui-icon-search"></a></li> -->
                 <!-- 站点切换 -->
                 {php}$info=get_addon_info('cms');{/php}
                 {if $info['dzd']}
                 <li class="layui-nav-item"><a href="javascript:;"><img src="__STATIC__/lang/image/{if getSiteInfo('mark')}{:getSiteInfo('mark')}{else}site{/if}.png" class="layui-nav-img userAvatar" width="35" height="35">{:onSiteName()}【切换】</a>
                     <dl class="layui-nav-child" id="change">
                         <dd><a href="javascript:;" data-type="0"><img class="site-icon" src= "/static/lang/image/site.png"> 所有站点</a></dd>
                         {volist name="sites" id="vo"}
                         <dd  {if getSiteInfo('id')==$vo['id']}class="layui-this"{/if}><a href="javascript:;" data-type="{$vo.id}"><img class="site-icon" src= "/static/lang/image/{$vo.mark}.png"> {$vo.name}</a></dd>
                         {/volist}
                     </dl>
                 </li>
                 {/if}
                <li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
                <li class="layui-nav-item"><a href="javascript:;"><i class="iconfont icon-trash" title="清空缓存"></i></a>
                        <dl class="layui-nav-child" id="deletecache">
                            <dd><a href="javascript:;" data-type="all">一键清理缓存<span class="layui-badge-dot"></span></a></dd>
                            <hr>
                            <dd><a href="javascript:;" data-type="data">清理数据缓存</a></dd>
                            <dd><a href="javascript:;" data-type="template">清理模板缓存</a></dd>
                            <dd><a href="javascript:;" data-type="addons">清理插件缓存</a></dd>
                        </dl>
                </li>
                <li class="layui-nav-item user">
                    <!-- 头 像 -->
                    <a href="javascript:;"><img src="__STATIC__/admin/img/avatar.png" class="layui-nav-img userAvatar" width="35" height="35">{$userInfo.username}</a>
                    <!-- 功 能 菜 单 -->
                    <dl class="layui-nav-child">
                        <dd><a user-menu-url="{:url('general.profile/index')}" user-menu-id="3" user-menu-title="个人资料"><i class="iconfont icon-user-line"></i>&nbsp;个人资料</a></dd>
                        <dd><a href="javascript:void(0);" class="logout"><i class="iconfont icon-logout-box-r-line"></i>&nbsp;注销登录</a></dd>
                    </dl>
                </li>
                <!-- 主 题 配 置 -->
                <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
            </ul>
        </div>
        <!-- 侧 边 区 域 -->
        <div class="layui-side layui-bg-black">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <div class="logo"><i class="layui-icon layui-icon-component"></i></div>
                <!-- 标 题 -->
                <span class="title">YznCMS后台</span>
            </div>
            <!-- 菜 单 内 容 -->
            <div class="layui-side-scroll">
                <div class="sider-search menuSearch">
                    <div class="search-input">
                        <span class="search-text">搜索菜单</span>
                        <div class="search-icon"><i class="layui-icon layui-icon-search"></i></div>
                    </div>
                </div>
                <div id="sideMenu"></div>
            </div>
        </div>
        <!-- 视 图 页 面 -->
        <div class="layui-body">
            <!-- 内 容 页 面 -->
            <div id="content"></div>
        </div>
        <!-- 页脚 -->
        <div class="layui-footer layui-text">
            <span class="left">
                <strong>Copyright © 2017-{:date("Y")}&nbsp;<a href="https://www.yzncms.com/">YznCMS</a>.</strong>&nbsp;All rights reserved.

            </span>
            <span class="center"></span>
            <span class="right">
                <b>Version</b>&nbsp;{$Think.config.version.yzncms_version}
            </span>
        </div>
        <!-- 遮 盖 层 -->
        <div class="pear-cover"></div>
        <!-- 加 载 动 画 -->
        <div class="loader-main">
            <!-- 动 画 对 象 -->
            <div class="loader"></div>
        </div>
    </div>
    <!-- 移 动 端 便 捷 操 作 -->
    <div class="pear-collapsed-pe collapse">
        <a href="#" class="layui-icon layui-icon-shrink-right"></a>
    </div>
    <!-- 依 赖 脚 本 -->
    <script src="__STATIC__/libs/layui/layui.js"></script>
    <script type="text/javascript">
    layui.config({
       base: '__STATIC__/libs/layui_exts/'
    }).extend({
       admin: "pear/admin",           // 框架布局组件
       tab: "pear/tab",               // 多选项卡组件
       menu: "pear/menu",             // 数据菜单组件
       frame: "pear/frame",           // 内容页面组件
       theme: "pear/theme",           // 主题转换
       fullscreen:"pear/fullscreen",  // 全屏组件
    }).use(['layer', 'theme'], function () {
        layui.theme.changeTheme(window, false);
    })

    layui.use(['admin'], function() {
        var admin = layui.admin;
        var $ = layui.jquery;

        admin.render({
            "menu": {
                "data": "{:url('index')}",
                "method": "POST",
                "accordion": true,
                "collapse": false,
                "control": false,//菜单模式 false 为常规菜单，true 为多系统菜单
                "select": 0,
                "async": true
            }, 
            "tab": {
                "enable": true,
                "keepState": true,
                "session": true,
                "preload": true,
                "max": "10", 
                "index": {
                    "id": 0,
                    "href":"{:url('main/index')}",
                    "title": "首页"
                }
            }, 
            "theme": {
                "defaultColor": "2",
                "defaultMenu": "dark-theme",
                "defaultHeader": "light-theme",
                "allowCustom": true,
                "banner": false
            },
            "colors": [
                    {"id": "1", "color": "#2d8cf0", "second": "#ecf5ff"}, 
                    {"id": "2", "color": "#36b368", "second": "#f0f9eb"}, 
                    {"id": "3", "color": "#f6ad55", "second": "#fdf6ec"}, 
                    {"id": "4", "color": "#f56c6c", "second": "#fef0f0"}, 
                    {"id": "5", "color": "#3963bc", "second": "#ecf5ff"}
                ], 
            "other": {
                "keepLoad": "1200",
                "autoHead": false,
                "footer": false
            }
        });

        // 登出逻辑 
        admin.logout(function(){
            location.href = "{:url('admin/index/logout')}";
            // 注销逻辑 返回 true / false
            return true;
        })

        //清除缓存
        $('body').on('click', "dl#deletecache dd a", function() {
            $.ajax({
                url: "{:url('admin/index/cache')}",
                dataType: 'json',
                data: { type: $(this).data("type") },
                cache: false,
                success: function(res) {
                    if (res.code == 1) {
                        var index = layer.msg('清除缓存中，请稍候', { icon: 16, time: false, shade: 0.8 });
                        setTimeout(function() {
                            layer.close(index);
                            layer.msg("缓存清除成功！");
                        }, 1000);
                    }else{
                        layer.msg('清除缓存失败');
                    }
                },
                error: function() {
                    layer.msg('清除缓存失败');
                }
            });
        });

        //切换站点
        $(document).on('click', "dl#change dd a", function() {
            $.ajax({
                url: '{:url("admin/cms.ajax/change")}',
                dataType: 'json',
                data: { type: $(this).data("type") },
                cache: false,
                success: function(res) {
                    if (res.code == 1) {
                        var index = layer.msg('切换站点中，请稍候', { icon: 16, time: false, shade: 0.8 });
                        setTimeout(function() {
                            layer.close(index);
                            layer.msg("切换站点成功！");
                            setTimeout('window.location.reload()',1000);
                        }, 1000);
                    }else{
                        layer.msg('切换站点失败');
                    }
                },
                error: function() {
                    layer.msg('切换站点失败');
                }
            });
        });
    })
    </script>
</body>

</html>